package javaAPI.StringPractice;

import java.util.Random;

public class StringPractice4 {
    public static void main(String[] args) {


        char[] chs = new char[52];
        for (int i = 0; i < chs.length; i++) {
            if (i <= 25) {
                //小写字母
                chs[i] = (char) (97 + i);
            } else {
                //当i>26时,添加大写字母
                chs[i] = (char) (65 + i - 26);
            }
        }
       /* for (int i = 0; i < chs.length; i++) {
            System.out.print(chs[i] + " ");
        }*/
        String result="";
        Random r = new Random();
        for (int i = 0; i < 2; i++) {
            int randomIndex = r.nextInt(chs.length);
            result=result+chs[randomIndex];
        }
        //System.out.print(result);
        for (int i = 0; i < 2; i++) {
            int number = r.nextInt(10);
            result = result + number;
        }
        result = Upset(result);
        System.out.println(result);
    }
    public static String Upset(String str){
        char[]arr=str.toCharArray();
        Random r=new Random();
        for (int i = 0; i < arr.length; i++) {
            int index=r.nextInt(arr.length);
            char Temp=arr[i];
            arr[i]=arr[index];
            arr[index]=Temp;
        }
        str=new String(arr);
        return  str;
    }
}
